package org.devgframwork.flowsystem.api.admin.activity.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.devgframwork.es5.elasticserach.EsResult;
import org.devgframwork.es5.elasticserach.EsSearch;
import org.devgframwork.flowsystem.api.admin.activity.entity.MerchandiseActivity;
import org.devgframwork.platform.model.ResultModel;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(value = "/api/admin/activity", tags = "活动管理")
@Slf4j
@RestController
public class ActivityController {

    @ApiOperation("活动测试")
    @GetMapping(value = {"/api/admin/activity/getActivityList"})
    public ResultModel<EsResult<MerchandiseActivity>> getActivityList() throws Exception {
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
        searchSourceBuilder.query(queryBuilder);
        EsResult<MerchandiseActivity> esResult = EsSearch.getEsResult(searchSourceBuilder, 1, 10, "b2b-third-activity", "activity", MerchandiseActivity.class);
        return ResultModel.newSuccess(esResult);
    }

}
